package mempool

//
//import (
//	"container/list"
//	"crypto/sha256"
//	tmsync "github.com/tendermint/tendermint/libs/sync"
//	"github.com/tendermint/tendermint/types"
//)
//
//type txCache interface {
//	Reset()
//	Push(tx types.Tx) bool
//	Remove(tx types.Tx)
//}
//
//// mapTxCache maintains a LRU cache of transactions. This only stores the hash
//// of the tx, due to memory concerns.
//type mapTxCache struct {
//	mtx      tmsync.Mutex
//	size     int
//	cacheMap map[[TxKeySize]byte]*list.Element
//	list     *list.List
//}
//
//var _ txCache = (*mapTxCache)(nil)
//
//// newMapTxCache returns a new mapTxCache.
//func newMapTxCache(cacheSize int) *mapTxCache {
//	return &mapTxCache{
//		size:     cacheSize,
//		cacheMap: make(map[[TxKeySize]byte]*list.Element, cacheSize),
//		list:     list.New(),
//	}
//}
//
//// Reset resets the cache to an empty state.
//func (cache *mapTxCache) Reset() {
//	cache.mtx.Lock()
//	cache.cacheMap = make(map[[TxKeySize]byte]*list.Element, cache.size)
//	cache.list.Init()
//	cache.mtx.Unlock()
//}
//
//// Push adds the given tx to the cache and returns true. It returns
//// false if tx is already in the cache.
//func (cache *mapTxCache) Push(tx types.Tx) bool {
//	cache.mtx.Lock()
//	defer cache.mtx.Unlock()
//
//	// Use the tx hash in the cache
//	txHash := TxKey(tx)
//	if moved, exists := cache.cacheMap[txHash]; exists {
//		cache.list.MoveToBack(moved)
//		return false
//	}
//
//	if cache.list.Len() >= cache.size {
//		popped := cache.list.Front()
//		if popped != nil {
//			poppedTxHash := popped.Value.([TxKeySize]byte)
//			delete(cache.cacheMap, poppedTxHash)
//			cache.list.Remove(popped)
//		}
//	}
//	e := cache.list.PushBack(txHash)
//	cache.cacheMap[txHash] = e
//	return true
//}
//
//// Remove removes the given tx from the cache.
//func (cache *mapTxCache) Remove(tx types.Tx) {
//	cache.mtx.Lock()
//	txHash := TxKey(tx)
//	popped := cache.cacheMap[txHash]
//	delete(cache.cacheMap, txHash)
//	if popped != nil {
//		cache.list.Remove(popped)
//	}
//
//	cache.mtx.Unlock()
//}
//
//type nopTxCache struct{}
//
//var _ txCache = (*nopTxCache)(nil)
//
//func (nopTxCache) Reset()             {}
//func (nopTxCache) Push(types.Tx) bool { return true }
//func (nopTxCache) Remove(types.Tx)    {}
//
////--------------------------------------------------------------------------------
//
//// TxKey is the fixed length array hash used as the key in maps.
//func TxKey(tx types.Tx) [TxKeySize]byte {
//	return sha256.Sum256(tx)
//}
//
//// txID is a hash of the Tx.
//func txID(tx []byte) []byte {
//	return types.Tx(tx).Hash()
//}
